<?php
/**
 * Created by PhpStorm.
 * User: liuchaozhong
 * Date: 2018/8/22
 * Time: 下午4:19
 */
namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class InviteLog extends Model
{
    protected $table = 'invite_log';
    protected $fillable = ['invite_id','binvite_id','it_date'];
    public $timestamps = false;

    //关联被邀请人用户关系
    public function g_bmember()
    {
        return $this->belongsTo(Member::class, 'binvite_id');
    }

    /**
     * 添加邀请记录
     * @param $invite_id  邀请人id
     * @param $binvite_id 被邀请人id
     */
    public function addInviteLog($invite_id, $binvite_id)
    {
        $insert = [
            'invite_id' => $invite_id,
            'binvite_id' => $binvite_id,
            'it_date' => date('Y-m-d')
        ];
        try {
            $res = InviteLog::create($insert);
        }catch (\Exception $e) {
            $res = false;
        }

        return $res ? $res : false;
    }

}
